# $NetBSD$

PHAROVM_VER=	9.0.22
PHAROVM_HASH=	421845e

DISTNAME=	PharoVM-${PHAROVM_VER}-${PHAROVM_HASH}-Linux-x86_64-c-src
PKGNAME=	pharo-vm-${PHAROVM_VER}
CATEGORIES=	lang
MASTER_SITES=	http://files.pharo.org/vm/pharo-spur64-headless/Linux-x86_64/source/
EXTRACT_SUFX=	.zip

MAINTAINER=	pkgsrc-users@NetBSD.org
HOMEPAGE=	https://pharo.org/
COMMENT=	VM used by Pharo
LICENSE=	mit

ONLY_FOR_PLATFORM=	NetBSD-[0-9]*-x86_64

WRKSRC=		${WRKDIR}/pharo-vm
USE_LANGUAGES=	c c++
USE_CMAKE=	yes

CMAKE_ARGS+=	-DFLAVOUR=CoInterpreter
CMAKE_ARGS+=	-DALWAYS_INTERACTIVE=1
CMAKE_ARGS+=	-DGENERATE_SOURCES=OFF
CMAKE_ARGS+=	-DPHARO_BIN_LOCATION=${PREFIX}/lib/pharo9

SUBST_CLASSES+=			fix-paths
SUBST_STAGE.fix-paths=		pre-build
SUBST_MESSAGE.fix-paths=	Fixing absolute paths.
SUBST_FILES.fix-paths=		packaging/linux/bin/launch.sh.in
SUBST_SED.fix-paths=		-e "s,@pkglibdir@,${PREFIX}/lib,g"

NOT_PAX_MPROTECT_SAFE+=	lib/pharo9/pharo

INSTALLATION_DIRS=	bin lib/pharo9

pre-configure:
	${CP} ${WRKSRC}/cmake/OpenBSD.cmake ${WRKSRC}/cmake/NetBSD.cmake

do-install:
	cd ${WRKSRC}/build/packaging/linux/bin && \
		${INSTALL_SCRIPT} pharo ${DESTDIR}${PREFIX}/bin/pharo9
	cd ${WRKSRC}/build/vm/ && \
		${INSTALL_PROGRAM} pharo ${DESTDIR}${PREFIX}/lib/pharo9
	cd ${WRKSRC}/build/vm/ && find . -type f -name "*.so" | while read file; do \
		${INSTALL_LIB} $$file ${DESTDIR}${PREFIX}/lib/pharo9; \
	done

.include "../../devel/SDL2/buildlink3.mk"
.include "../../devel/libffi/buildlink3.mk"
.include "../../devel/libgit2/buildlink3.mk"
.include "../../graphics/cairo/buildlink3.mk"
.include "../../graphics/freetype2/buildlink3.mk"
.include "../../security/openssl/buildlink3.mk"

.include "../../mk/bsd.pkg.mk"
